extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	name = "[稀有]基因诱变药剂"
	info = "一次性消耗品，将使用者随机进化\n65%进化为高一级的随机舰娘\n20%进化为高二级的随机舰娘\n14%进化失败，1%退化\n有概率获得限定池舰娘"
	price = 300
func _connect():
	._connect()
	if masCha.lv > 3 or masCha.type == sys.CharaClass.NPC:return
	var rndNum = sys.rndRan(1, 100)
	if masCha.lv == 3:
		if rndNum <= 85:
			doEvo4()
		elif rndNum <= 86:
			doFail()
	else:
		if rndNum <= 65:
			doEvo(masCha.lv + 1)
		elif rndNum <= 85:
			doEvo(masCha.lv + 2)
		elif rndNum <= 86:
			doFail()
	delSelf()

func doEvo(lv):
	#获得限定建造
	if sys.rndPer(8):
		var upcha = sys.rndListItem(chaData.upChas)
		var evoId = chaData.getLvIds(upcha.id, lv)
		sys.main.evoCha(masCha, evoId, false)

	match lv:
		2:doEvo2()
		3:doEvo3()
		4:doEvo4()

func doEvo4():
	var chas = chaData.infosLv4
	var cha = sys.main.evoCha(masCha, sys.rndListItem(chas).id, false)
	cha.isDrag = true

func doEvo3():
	var chas = chaData.infosLv3
	var cha = sys.main.evoCha(masCha, sys.rndListItem(chas).id, false)
	cha.isDrag = true

func doEvo2():
	var chas = chaData.infosLv2
	var cha = sys.main.evoCha(masCha, sys.rndListItem(chas).id, false)
	cha.isDrag = true

#退化
func doFail():
	var cid = chaData.getLvIds(masCha.id, masCha.lv-1)
	if cid != null or cid == masCha.id:return
	var cha = sys.main.evoCha(masCha, cid, false)
	cha.isDrag = true